<template>
    <bi-form ref="form">
        <bi-form-item label="分组名称" >
            <bi-input  v-model="form.title" required ></bi-input>
        </bi-form-item>
        <bi-form-item label="上级分组" >
            <block-group root v-model="form.parent_id" required  :disabled-list="disabledList"  ></block-group>
        </bi-form-item>
        <bi-form-item label="分组简介" >
            <bi-textarea  v-model="item.brief" ></bi-textarea>
        </bi-form-item>
    </bi-form>
</template>

<script>
import blockGroup from '../field/block-group.vue';

export default{
    components:{
        blockGroup
    },
    props:{
        item:Object
    },
    data(){

        let form = {
                blockgroup_id:'',
                title:'',
                brief:'',
                parent_id:0
        }

        this.$assign(form,this.item);

        let disabledList = [];
        if (form.blockgroup_id!=''){
            disabledList.push(form.blockgroup_id);
        }


        return {
            form   ,
            disabledList    
        }
    },
    methods:{
        dialogOk(){
            if (this.$refs.form.check()){
                this.$ajax({
                    url:this.$url({app:'web',controller:'admin.block',action:'groupSave'}),
                    data:this.form,
                    success:(data)=>{
                        this.$toast('保存成功');
                        this.dialog.callback();
                        this.dialog.close();
                    }
                });
            }

            return false;
        }
    }
}

</script>